package model;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * This class represents a paper object
 * 
 * @author Rylie Nelson, Eric Preston
 */
public class Paper implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3018532214661774921L;
	
	private User subProgramChair;

	/**
	 * The text of the paper
	 */
	private File text;
	
	/**
	 * The author of the paper
	 */
	private User author;
	
	/**
	 * The paper's reviews
	 */
	private ArrayList<Review> reviews;
	
	/**
	 * The list of reviewers
	 */
	private List<User> reviewers;
	
	/**
	 * The paper's recommendation
	 */
	private Recommendation recomendation;
	
	/**
	 * Stores if the paper has been accepted to the conference
	 */
	
	private boolean accepted;
	
	/**
	 * TITLES!!! I LOVE TITLES!!!
	 */
	private String title;
	
	/** The category of the paper. */
	private String category;
	
	/** The keywords associated with the paper. */
	private String keyword;
	
	/** The abstract for the paper. */
	private String abStract;
	
	/**
	 * Constructor for a paper object
	 * @param input_text The text of the paper
	 * @param input_author The author of the paper
	 */
	public Paper(File input_text, User input_author, String input_title, String input_category, 
			String input_keyword, String input_abstract) {
		title = input_title;
		text = input_text;
		author = input_author;
		accepted = false;
		reviews = new ArrayList<Review>();
		category = input_category;
		keyword = input_keyword;
		abStract = input_abstract;
		subProgramChair = null;
		reviewers = new ArrayList<User>();
	}
	
	public Paper(File input_text, String input_title, String input_category, 
			String input_keyword, String input_abstract) {
		title = input_title;
		text = input_text;
		accepted = false;
		reviews = new ArrayList<Review>();
		category = input_category;
		keyword = input_keyword;
		abStract = input_abstract;
		subProgramChair = null;
		reviewers = new ArrayList<User>();
	}
	
	public void addAuthor(User aut) {
		author = aut;
	}

	
	/**
	 * Returns the title of this paper.
	 * @return title The paper's title.
	 */
	public String getTitle() {
		return title;
	}
	
	/**
	 * Returns the reviews for this paper
	 * @return the reviews for this paper
	 */
	public ArrayList<Review> getReviews() {
		return reviews;
	}
	
	/**
	 * Adds a review to this paper
	 * @param rev the review to be added
	 */
	public void addReview(Review rev) {
		reviews.add(rev);
	}
	
	/**
	 * Adds a list of reviewers to this paper.
	 * @param revs an arraylist of users.
	 */
	public void addReviewers(List<User> revs) {
		reviewers = revs;
	}
	
	/**
	 * returns the reviewers of this paper.
	 * @return reviewers an arraylist of users.
	 */
	public List<User> getReviewers() {
		return reviewers;
	}
	
	/**
	 * Adds a recommendation to this paper
	 * @param rec the recommendation to be added
	 */
	public void addRecommendation(Recommendation rec) {
		recomendation = rec;
	}
	
	/**
	 * Gets the current recommendation.
	 * @return recommendation This paper's recommendation.
	 */
	public Recommendation getRecommendation() {
		return recomendation;	
	}
	
	/**
	 * Returns whether or not this paper has been accepted
	 * @return whether or not this paper has been accepted
	 */
	public boolean isAccepted() {
		return accepted;
	}
	
	/**
	 * Sets whether or not this paper has been accepted
	 * @param acc accepted status
	 */
	public void setAccepted(boolean acc) {
		accepted = acc;
	}
	
	/**
	 * Returns the author of this paper
	 * @return the author of this paper
	 */
	public String getAuthor() {
		return author.getName();
	}
	
	public User getAuthorObject() {
		return author;
	}
	
	/**
	 * Allows a user to upload a different version of the text (for editing purposes)
	 * @param txt the new version of the text
	 */
	public void uploadNewText(File txt) {
		text = txt;
	}
	
	/**
	 * returns the paper for downloading.
	 * @return text the text of the paper.
	 */
	public File getPaper() {
		return text;
	}
	
	public User getSPC() {
		return subProgramChair;
	}
	
	public void setSPC(User input_SPC) {
		subProgramChair = input_SPC;
	}
}
